package com.yidian.controller.system;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yidian.entity.PageResult;
import com.yidian.pojo.system.LoginLog;
import com.yidian.server.system.LoginLogService;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author whb
 * @create 2021-06-09 14:09
 * @desciption 登录日志控制类
 */
@RestController
@RequestMapping("/loginLog")
public class LoginLogController {
    @Reference
    private LoginLogService loginLogService;

    @GetMapping("/findPage")
    public PageResult<LoginLog> findPageByLogin(int page, int size) {
        String loginName = SecurityContextHolder.getContext().getAuthentication().getName();
        Map<String, Object> map = new HashMap<>();
        map.put("loginName", loginName);
        return loginLogService.findPage(map, page, size);
    }
}
